<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <div id="box">xx</div>

    <script>
        console.log('111');
        box.onclick = function () {
            console.log('333');
        }
        setTimeout(function () {
            console.log('444')
        }, 0)
        let promise = new Promise((resolve, reject) => {
            // promise中的内容是同步代码
            console.log('555');
            if (true) {
                resolve('666');
            } else {
                reject('777');
            }
        })

        promise.then((data) => {
            console.log(data);
        })
        promise.finally(() => {
            console.log('888');
        })
        promise.catch((err) => {
            console.log(err);
        })
        console.log('222');

        //1 2 5 6 8 4 
        // 1 5 2 6 8 4 
    </script>
</body>

</html>